<style scoped lang="scss">
	.title{
		font-weight: bold;
		font-size: 46rpx;
	}

</style>
<template>
	<view class="auto-90">
		<text class="text-center title d-block pt-3 py-1">{{title}}</text>
		<text class="d-block color-999 font-30 text-center py-2">日期:{{create_time}}</text>
		<button type="default" size="mini" class="primary-btn d-block mx-auto mb-3" @click="set_collect" style="width: 200rpx;" :plain="!is_collect">{{is_collect?'已收藏':'收藏'}}</button>
		<rich-text :nodes="content" class="mt-3" ></rich-text>
	</view>
</template>

<script>
	import {getPolicyDetails,setCollect} from "@api"
	export default {
		data() {
			return {
				id:0,
				title:'',
				content:'',
				create_time:'',
				is_collect:false
				
			}
		},
		methods: {
			set_collect(){
				setCollect({
					openid:uni.getStorageSync('openid'),
					id:this.id,
					is:!this.is_collect
				})
				.then(res=>{
					if(res.data)
						this.is_collect=!this.is_collect
				})
			}
		},
		onLoad(option) {
			getPolicyDetails({...option,openid:uni.getStorageSync('openid')})
			.then(res=>{
				this.id=option.id
				this.title=res.data.title
				this.create_time=res.data.create_time
				this.content=res.data.content.replace(/<img src="/g,`<img style='width:100%' src="${this.$outDomain}`);
				this.is_collect=res.data.is_collect
			})
		}
	}
</script>